package home.game.entity;

import javax.persistence.*;
import java.util.Date;

/**
 */
@Entity(name = "users")
@NamedQueries({@NamedQuery(name = "findByPlayerName", query = "select u from users u where u.playerName = :name"),
        @NamedQuery(name = "findTopScores", query = "select u from users u order by (u.score) DESC")})

public class User implements Cloneable {

    public static final String FIND_BY_NAME = "findByPlayerName";
    public static final String FIND_TOP_SCORES = "findTopScores";

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private String playerName;
    private long score;
    private Date lastPlayed;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPlayerName() {
        return playerName;
    }

    public void setPlayerName(String playerName) {
        this.playerName = playerName;
    }

    public long getScore() {
        return score;
    }

    public void setScore(long score) {
        this.score = score;
    }

    public Date getLastPlayed() {
        return lastPlayed;
    }

    public void setLastPlayed(Date lastPlayed) {
        this.lastPlayed = lastPlayed;
    }

    @Override
    public Object clone() {
        User clone = new User();
        clone.setId(getId());
        clone.setPlayerName(getPlayerName());
        clone.setScore(getScore());
        clone.setLastPlayed(getLastPlayed());
        return clone;

    }
}
